When developing or debugging an application, a developer may employ logging mechanisms such as Unified Logging System (ULS) or Event Tracing for Windows (ETW) when writing to a log file stored in a file system. A log file typically includes a vast number of log messages, and each log message contains information that can be viewed by a developer to diagnose and correct problems that have occurred. Log files may be opened and read by a developer using a text editor or log viewer application.
A developer may write to a log file using a trace writing method such as: WriteTrace(System.UInt32, Microsoft.SharePoint.Administration.SPDiagnosticsCategory, Microsoft.SharePoint.Administration.TraceSeverity, System. String, System.Object[ ]);. When using the trace writing method, the developer often will provide a string containing formatting placeholders so that the string is passed to System. String.Format(string, Object[ ]) for formatting.
Developers conventionally use print-formatted (printf) style string logging to create log files. Printf-based string logging allows developers to create free form log messages that include message text and formatting placeholders (e.g., % d, % s, etc.) which are replaced by values of variables when a printf statement is executed.
Since the content of each individual log message is free form, log files tend to lack consistency. The lack of consistency within a log file makes it more difficult for a developer to read the log file and locate necessary information. When searching for information pertaining to a certain problem, a developer often may have to perform a regular expression (regex) search on the message strings to determine which logs are of interest and then will have to search again within the logs of interest to extract the necessary information. The lack of consistency within a log file and the lack of consistency among log files also make it difficult to design computer programs for analyzing log files and to do broad log analysis with machines.
Moreover, creating string-based logs negatively impacts the performance of an application. Namely, generating a large log file for an application involves the use and consumption of important computing, processing, and/or storage resources.